//package com.woniuxy;
//
//import com.rabbitmq.client.*;
//
//import java.io.IOException;
//import java.util.concurrent.TimeoutException;
//
//public class MQRecvMessage {
//    public static void main(String[] args) throws IOException, TimeoutException, InterruptedException {
//        ConnectionFactory connectionFactory=new ConnectionFactory();
//        connectionFactory.setHost("localhost");
//        connectionFactory.setUsername("guest");
//        connectionFactory.setPassword("guest");
//        connectionFactory.setPort(5672);
//        Channel channel=connectionFactory.newConnection().createChannel();
//        channel.queueDeclare("my_queue", false, false, false, null);
//        Consumer consumer = new DefaultConsumer(channel){
//            @Override
//            public void handleDelivery(String consumerTag, Envelope envelope,
//                                       AMQP.BasicProperties properties, byte[] body) throws IOException {
//                String message = new String(body, "UTF-8");
//                System.out.println("消费者获取到了消息："+message);
//            }
//        };
//        channel.basicConsume("my_queue",true,consumer);
//        Thread.sleep(3000);
//        channel.close();
//        connectionFactory.clone();
//    }
//}
